<?php
	include "common.php";
	error_reporting(0);
	session_start();
	if($_SESSION['logInCheck']!=1){
		header('Location: index.php?loginInfo=false');
	}
	$userLink = $_SESSION['userLink'];
	if($userLink!="hrpage.php"){
		echo "Sorry, You have no right to visit this page!!";
		exit;
	}
	$userName = $_SESSION['userName'];
	$ID = $_SESSION['id'];
	$supervisor = $_SESSION['supervisor'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="index.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="hr_attendance.css" />
<link rel="icon" type="image/ico" href="images/favicon.ico"></link> 
<link rel="shortcut icon" href="images/favicon.ico"></link>
<script src="curvycorners.src.js" type="text/javascript"></script>
<script src="login.js" type="text/javascript"></script>
<title>Add Employee</title>
</head>

<body>
<div class="main_div_other">
	<p><img src="images/creato_logo.jpg" /></p>
    <p id="creatobd">www.creatobd.com</p>
    <p id="date"><script>document.write(new_month+" "+new_date+", "+old_date.getFullYear()+" || "+new_day);</script></p>
    <div class="other_page_icons">
    	<div class="new_notification">
        	<img src="images/arrow_up.JPG" /><p>You have a new notification</p>
        </div><!--end of new_notification-->
    	<ul>
        	<a href="hrpage.php"><li><div id="home"></div><p>home</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_employee.php" class="active"><li><div id="employee"></div><p>employee</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_onduty.php"><li><div id="onduty"></div><p>on duty</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_attendance.php"><li><div id="attendance"></div><p>attendance</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_leave.php"><li><div id="leave"></div><p>leave</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_notification.php"><li><div id="notification"></div><p>notification</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="hr_black_box_message.php"><li><div id="blackbox"></div><p>black box</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="#"><li><div id="hrpolicy"></div><p>hr policy</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="index.php"><li><div id="logout"></div><p>log out</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
        </ul>
    </div><!-- end of other_page_icons-->
    
</div><!-- end of main_div_other-->
<div class="othrpage_1">
    <p>view as: <a href="hr_employee_lists.php">lists</a> | <a href="update_user.php">add</a> | <a href="up_user.php">Update</a></p>
</div><!-- end of othrpage_1-->
<form method="post" action="get_hr.php" class="update_user_add_table">
			<table cellpadding="0" cellspacing="0" class="apply4leave_table" align='center'>
				<tr valign="top">
					<td class="add_user_td1">Emoloyee ID</td>
					<td><input type="text" name="e_id" class="add_user_input"/></td>
					<td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
				<tr valign="top">
					<td class="add_user_td1">Add as</td>
					<td>
                    	<select name="role">
                        	<option value="1">CEO</option>
                            <option value="2">HR Admin</option>
                            <option value="3">Employee</option>
                        </select>
                    </td>
                    <td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
				<tr valign="top">
					<td class="add_user_td1">First Name</td>
					<td><input type="text" name="f_name" class="add_user_input"/></td>
					<td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
				<tr valign="top">
					<td class="add_user_td1">Last Name</td>
					<td><input type="text" name="l_name" class="add_user_input"/></td>
					<td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
				<tr valign="top">
					<td class="add_user_td1">Email</td>
					<td><input type="text" name="email" class="add_user_input"/></td>
					<td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
                <tr valign="top">	
					<td class="add_user_td1">Password</td>
					<td><input type="password" name="pass" class="add_user_input"/></td>
					<td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
                <tr valign="top">
					<td class="add_user_td1">Contact I</td>
					<td><input type="text" name="cnt1" class="add_user_input"/></td>
					<td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
                <tr valign="top">
					<td class="add_user_td1">Contact II</td>
					<td><input type="text" name="cnt2" class="add_user_input"/></td>
					<td class="add_user_td2"><p>(Optional)</p></td>
				</tr>
				<tr valign="top">
					<td class="add_user_td1">Select Supervisor</td>
					<td>
						<?php
							$collectAllEmp = "SELECT * FROM user WHERE status=0 ORDER BY f_name";
							$collectAllEmpQuery = mysql_query($collectAllEmp);
						?>                        
							<select name="super">
                            <?php
							while($collectAllEmpFetchArray=mysql_fetch_array($collectAllEmpQuery)){
								$collectId = $collectAllEmpFetchArray['e_id'];
								$collectRole = $collectAllEmpFetchArray['role'];
								$collectFname = $collectAllEmpFetchArray['f_name'];
								$collectLname = $collectAllEmpFetchArray['l_name'];
								if($collectRole==1){
								?>
                                	<option value="<?php echo $collectId; ?>" selected="selected"><?php echo $collectFname." ".$collectLname;?></option>
                                <?php
								}
								?>                           
                                <option value="<?php echo $collectId; ?>"><?php echo $collectFname." ".$collectLname;?></option>
                                <?php
							}
						?>
                        	</select>
					</td>
					<td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
				<tr valign="top">
					<td class="add_user_td1">Address</td>
					<td><input type="text" name="add" class="add_user_input"/></td>
					<td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
				<tr valign="top">
					<td class="add_user_td1">Blood Group</td>
					<td>
                    	<select name="blood">
                        	<option value="Unknown">Unknown</option>
                        	<option value="O-">O-</option>
                            <option value="O+">O+</option>
                            <option value="A-">A-</option>
                            <option value="A+">A+</option>
                            <option value="B-">B-</option>
                            <option value="B+">B+</option>
                            <option value="AB-">AB-</option>
                            <option value="AB+">AB+</option>
                        </select>
                    </td>
                    <td class="add_user_td2"><p>&nbsp;</p></td>
				</tr>
				<tr valign="top">
					<td class="add_user_td1">Joining Date</td>
					<td><input type="text" name="j_date" class="add_user_input"/></td>
					<td class="add_user_td2"><p>(YYYY - MM - DD)</p></td>
				</tr>
				<!--<tr valign="top">
					<td>Department ID</td>
					<td><input type="text" name="dept_id" /></td>
				</tr>
				<tr valign="top">
					<td>Status</td>
					<td><input type="text" name="status"/></td>
				</tr>-->
				<tr>
					<td colspan='3'><p class="submit_button_add_user"><input type="submit" value="Submit"/></p></td>
				</tr>
			</table>
		</form>
<div class="human_portal">
  		<p>creato human resourse portal</p>
</div><!-- end of human_portal-->

</body>

</html>
<?php

	$designation = $_POST['desig'];
	$dept_name = $_POST['dept_name'];
	$isCheckSubmit = $_POST['isCheck'];
	
	if($isCheckSubmit == 1){
	
		$e_id = $_POST['eid'];
		$Role = $_POST['role'];
		$Dept_id = $_POST['deptId'];
		$Supervisor = $_POST['supervisor'];
		$Status = $_POST['status'];
		
		$organogramSql = "INSERT INTO company_organogram (e_id,e_designation,e_level,dept,supervisor,status)
		VALUES ('$e_id','$designation','$Role','$dept_name','$Supervisor','$Status')";
		
		$organogramSqlResult = mysql_query($organogramSql);
	
	}	
?>